package com.google.code.sapwcrawler.download.cycle;

import java.net.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.code.sapwcrawler.download.procedure.DownloadProc;

abstract public class DownloadCycle implements Runnable
{
	static private Logger logger = Logger.getLogger(DownloadCycle.class.getName());
	private DownloadProc procedure;
	private Queue<URL> queue = new LinkedList<URL>();
	
	public void setDownloadProc(DownloadProc v)
	{
		this.procedure = v;
	}
	
	final protected Queue<URL> getQueue()
	{
		return queue;
	}
	
	final protected DownloadProc getDownloadProc()
	{
		return procedure;
	}
	
	public void addUrl(URL url)
	{
		queue.add(url);
	}
	
	public void addUrls(List<URL> list)
	{
		queue.addAll(list);
	}
	
	protected void handleException(Throwable e)
	{
		logger.log(Level.WARNING,e.toString());
	}
}
